#include "AVLTree.hpp"
#include "vld.h"
#include <vector>

using namespace std;

void test1()
{
	pair<int, string> pr(7, "hahaha");
	AVLTree<int, string> t;
	t.insert(pr);
	t.insert({ 6, "liu" });
	t.insert({ 4, "si" });
	t.insert({ 3, "san" });
	t.insert({ 5, "wu" });
	t.insert({ 2, "er" });
	
	t.insert({ 9, "jiu" });
	t.insert({ 10, "shi" });
	t.insert({ 8, "ba" });
	t.insert({ 11, "shiyi" });
	cout << "Height = " << t.height() << endl;
	cout << "IsBalance = " << t.isBalance() << endl;

	auto n = t.find(4);
	n->_value = "SI";
	t.inorder();
}

void test2()
{
	AVLTree<int> t;
	vector<int> v{ 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto e : v)
	{
		printf("insert num: %d\n", e);
		t.insert(e);
	}

	cout << "Height = " << t.height() << endl;
	cout << "IsBalance = " << t.isBalance() << endl;
	t.inorder();
}

void test3()
{
	AVLTreeNode<int> n1(20);
	AVLTreeNode<int> n2(10);
	AVLTreeNode<int>* p1 = &n1;
	AVLTreeNode<int>* p2 = &n2;
	if (*p1 < *p2)
	{
		cout << "n1 < n2" << endl;
	}
}

int main()
{
	test1();
	cout << "##########################" << endl;
	//test3();
	//cout << "##########################" << endl;
	test2();


	return 0;
}